package com.tencentcloudapi.apitest;

import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.live.v20180801.LiveClient;
import com.tencentcloudapi.live.v20180801.models.DescribeLiveStreamPublishedListRequest;
import com.tencentcloudapi.live.v20180801.models.DescribeLiveStreamPublishedListResponse;

/* ━━━━━━佛祖保佑━━━━━━
 *                  ,;,,;
 *                ,;;'(    社
 *      __      ,;;' ' \   会
 *   /'  '\'~~'~' \ /'\.)  主
 * ,;(      )    /  |.     义
 *,;' \    /-.,,(   ) \    码
 *     ) /       ) / )|    农
 *     ||        ||  \)
 *     (_\       (_\
 * ━━━━━━永无BUG━━━━━━
 * @author ：zjq
 * @date ：2021/3/28 1:50
 *        参考文档       https://console.cloud.tencent.com/api/explorer?Product=live&Version=2018-08-01&Action=DescribeLiveStreamPublishedList&SignVersion=
 * @description: TODO   腾讯云直播 api
 *                      SecretId：            AKIDVt21kE9tMgTX3IQ5dfqreDtQmusHQdah
 *                      SecretKey：           h8LIzUkkZBYgaFhsoeHemeGgsoUv67sO
 * @version: V1.0
 * @slogan: 天下风云出我辈，一入代码岁月催
 */
public class LiveApiTest {

    private static String SecretId = "AKIDVt21kE9tMgTX3IQ5dfqreDtQmusHQdah";
    private static String SecretKey = "h8LIzUkkZBYgaFhsoeHemeGgsoUv67sO";

    public static void main(String[] args) {

        DescribeLiveStreamPublishedList("main.livepush.huanbaotech.cn", "2021-03-20T19:00:00Z",
                "2021-03-30T19:00:00Z", "", "", 1, 100);
    }

    /**
     * 查询历史流列表
     *
     * @param domainName 推流域名，配置在腾讯云 main.livepush.huanbaotech.cn
     * @param startTime  开始时间 utc 格式 2021-03-30T19:00:00Z
     * @param endTime    结束时间 同上 ，相差吧態超过60天
     *                   以下为 选填
     * @param appName
     * @param streamName
     * @param pageNum
     * @param pageSize
     */
    public static void DescribeLiveStreamPublishedList(String domainName, String startTime, String endTime, String appName,
                                                       String streamName, int pageNum, int pageSize) {
        try {

            Credential cred = new Credential(SecretId, SecretKey);

            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("live.tencentcloudapi.com");

            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);

            LiveClient client = new LiveClient(cred, "", clientProfile);

            DescribeLiveStreamPublishedListRequest req = new DescribeLiveStreamPublishedListRequest();
            req.setDomainName(domainName);
            req.setStartTime(startTime);
            req.setEndTime(endTime);
            req.setAppName(appName);
            req.setStreamName(streamName);
            req.setPageNum(1L);
            req.setPageSize(100L);


            DescribeLiveStreamPublishedListResponse resp = client.DescribeLiveStreamPublishedList(req);

            System.out.println(DescribeLiveStreamPublishedListResponse.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }

    }


}
